package com.thx.privilege.model;

import java.util.ArrayList;
import java.util.List;

import com.thx.privilege.PriviObj;

public class PriviObjImpl implements PriviObj{

	private String id;
	private String name;
	private String type;
	private List<PriviObjImpl> pos;
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}


	public List<PriviObjImpl> getPos() {
		return pos;
	}

	public void setPos(List<PriviObjImpl> pos) {
		this.pos = pos;
	}

	@Override
	public String getObjId() {
		return id;
	}

	@Override
	public String getObjName() {
		return null;
	}

	@Override
	public String getPriviType() {
		return type;
	}

	@Override
	public List<PriviObj> getChildren() {
		List<PriviObj> children = new ArrayList<PriviObj>();
		for(PriviObjImpl po : pos){
			children.add(po);
		}
		return children;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PriviObjImpl other = (PriviObjImpl) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		return true;
	}

	
}
